package com.yingpai.fitness.adpter.dynamic;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.support.annotation.LayoutRes;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yingpai.fitness.R;
import com.yingpai.fitness.dvp_2_0.main.activity.dynamic.DynamicDetailActivity;
import com.yingpai.fitness.entity.dynamic.DynamicBeanDetail;

import de.hdodenhof.circleimageview.CircleImageView;


public class DynamicCommentParentRecyclerAdapter extends BaseQuickAdapter<DynamicBeanDetail.MapBean.PageInfoBean.ListBean, BaseViewHolder> {


    private Activity activity;


    public DynamicCommentParentRecyclerAdapter(@LayoutRes int layoutResId, Activity
            activity) {

        super(layoutResId);
        this.activity = activity;
    }



    @Override
    protected void convert(BaseViewHolder helper, DynamicBeanDetail.MapBean.PageInfoBean.ListBean item) {
        CircleImageView  dynamic_comment_parent_user_head_iv=helper.getView(R.id.dynamic_comment_parent_user_head_iv);//用户头像

        Glide.with(activity).load(item.getCustomerPhotoUrl()).centerCrop().into(dynamic_comment_parent_user_head_iv);

        helper.addOnClickListener(R.id.dynamic_comment_parent_user_head_iv);//用户头像点击监听


        TextView dynamic_comment_parent_user_name=helper.getView(R.id.dynamic_comment_parent_user_name);//用户名
        dynamic_comment_parent_user_name.setText(item.getCustomerName());

        ImageView dynamic_comment_parent_user_apply =helper.getView(R.id.dynamic_comment_parent_user_apply);//回复
        helper.addOnClickListener(R.id.dynamic_comment_parent_user_apply);//回复点击监听


        TextView dynamic_comment_parent_user_like_count=helper.getView(R.id.dynamic_comment_parent_user_like_count);//喜欢人数
        dynamic_comment_parent_user_like_count.setText(item.getPraiseNo()+"");
        if(item.getIsPraised()==0){
            helper.getView(R.id.dynamic_comment_parent_user_like_count).setClickable(true);
            helper.addOnClickListener(R.id.dynamic_comment_parent_user_like_count);//喜欢点击监听
            Drawable drawable = activity.getResources().getDrawable(R.mipmap.bbs_like_no);// 找到资源图片// 这一步必须要做，否则不会显示。
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());// 设置图片宽高
            dynamic_comment_parent_user_like_count.setCompoundDrawables(drawable, null, null, null);// 设置到控件中

        }else{
            helper.getView(R.id.dynamic_comment_parent_user_like_count).setClickable(false);
            Drawable drawable = activity.getResources().getDrawable(R.mipmap.bbs_like);// 找到资源图片// 这一步必须要做，否则不会显示。
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());// 设置图片宽高
            dynamic_comment_parent_user_like_count.setCompoundDrawables(drawable, null, null, null);// 设置到控件中
        }


        TextView dynamic_comment_parent_user_date=helper.getView(R.id.dynamic_comment_parent_user_date); //日期
        dynamic_comment_parent_user_date.setText(item.getPublishTime());


        TextView dynamic_comment_user_content=helper.getView(R.id.dynamic_comment_user_content); //内容
        dynamic_comment_user_content.setText(item.getContent());

        if(item.getPublisherReply()==null){
            helper.getView(R.id.reply).setVisibility(View.GONE);
        }else{
            helper.getView(R.id.reply).setVisibility(View.VISIBLE);
            helper.setText(R.id.reply,item.getPublisherReply()+"");
        }

    }
}
